﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CompanyExceptions
{
    class Person
    {
        private string firstName;
        private string lastName;

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                for (int i = 0; i < value.Length; i++)
                {
                    if (char.IsLetter(value[i]) != true)
                    {
                        throw new ArgumentException("First name is not correct!Only letters are allowed in a name!");
                    }
                }
                if (value.Length < 4)
                {
                    throw new ArgumentException("Last name is not correct! The name should be at least 4 characters.");
                }
                else
                {
                    firstName = value;
                }
            }
        }


        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                for (int i = 0; i < value.Length; i++)
                {
                    if (char.IsLetter(value[i]) != true )
                    {
                        throw new ArgumentException("Last name is not correct! Only letters are allowed in a name!");
                    }
                }
                if (value.Length < 4)
                {
                    throw new ArgumentException("Last name is not correct! The name should be at least 4 characters.");
                }
                else
                {
                    lastName = value;
                }
            }
        }

        public Person(string firstName, string lastName)
        {
            this.FirstName = firstName;
            this.LastName = lastName;
        }
    }
}
